home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 8: LINUX Games / Linux Cubed Series 8 - LINUX Games.iso / games / x11 / strategy / xpuzzles.3 / xpuzzles / xpuzzles-5.3.1 / xhexagons / README < prev    next >
Text File  |  1996-04-08  |  8KB  |  227 lines

  1.     X-BASED HEXAGONS
  2.     ================    Hexagons X widget, V5.3
  3.  
  4.  
  5.     It has been tested on the following platforms:
  6.  
  7.     HP 3xx & 700        HP-UX 9.0x    X11R5
  8.     Sun4, SPARC        SunOS 4.1.3    X11R4
  9.     Sun4, SPARC        SunOS 5.4    X11R5
  10.     PC, 486            Linux 1.0.9    X11R5
  11.     PC, 486            Linux 1.2.8    X11R6(*)
  12.  
  13.     *    Keypad may not work, since various keycodes may not be defined
  14.     by default.  Check that "KP_1 - KP_9, Home, Up, Prior, Left,
  15.     Begin, Right, End, Down, Next" are defined towards the end of
  16.     /usr/lib/X11/etc/xmodmap.std .  If not defined
  17.     cp /usr/lib/X11/etc/xmodmap.std /usr/lib/X11/xinit/.Xmodmap
  18.     and then motify this or create your own at ${HOME}/.Xmodmap .
  19.     You should just have to uncomment them (get rid of some '!').
  20.  
  21.     If yours is not in this list, please let me know -- thanks. The
  22.     most updated source could be found on ftp.x.org under
  23.     /contrib/games/puzzles.
  24.  
  25. HOW TO BUILD?
  26.  
  27.     It should be easy. Edit the Imakefile (or Makefile.std, see below)
  28.     for appropriate settings of variable SCOREFILE, then do:
  29.     xmkmf
  30.     make
  31.     xhexagons  [motif version will be xmhexagons]
  32.  
  33.     Note: if you don't have 'xmkmf' or the "Makefile" it generates
  34.     doesn't work well, edit Makefile.std for appropriate settings for
  35.     XINCLUDEPATH and XLIBPATH, then try:
  36.     make -f Makefile.std
  37.     xhexagons
  38.  
  39.     or if you have Motif, uncomment appropriate sections, then try:
  40.     make -f Makefile.std all.xm
  41.     xmhexagons
  42.  
  43.     You should have Hexagons.ad copied to $(HOME)/Hexagons or 
  44.     /usr/lib/X11/app-defaults/Hexagons to run, especially if the background
  45.     is similar to one of the faces. Edit this file for your preferences.
  46.     You might want to move xhexagons into /usr/bin/X11 (or wherever your
  47.     X binaries are).
  48.     You might also want to move xhexagons.man to /usr/man/man6/xhexagons.6
  49.  
  50. ANYTHING SPECIAL IN USING?
  51.  
  52.     Click on the left mouse button to move tile.  If in corners mode,
  53.       a free tile will not move until released on a space.
  54.     Click on the right mouse button if you want to randomize the puzzle.
  55.       Also 'R' or 'r' does the same thing.  One must double click on
  56.       the right mouse button if the puzzle is being worked on.
  57.     'I' or 'i' to increase or move up the number of hexagons.
  58.     'D' or 'd' to decrease or move down the number of hexagons.
  59.     'C' or 'c' to toggle corners mode.  (Default is on).
  60.     'S' or 's' to auto-solve.  Unfortunately, its unimplemented.
  61.     'U' or 'u' to undo last move.
  62.     'G' or 'g' to get a saved puzzle.
  63.     'W' or 'w' to write or save a puzzle.
  64.     'Q', 'q', or Control-C to kill program.
  65.  
  66.     Key pad is defined for Hexagons as:
  67.     7       9
  68.         ^
  69.     4 <   > 6
  70.         v
  71.     1       3 
  72.  
  73.     Tiles can also be moved by the keypad,
  74.     KP_7=>TopLeft       KP_9=>TopRight
  75.     KP=>Left            KP_6=>Right
  76.     KP_1=>BottomLeft    KP_3=>BottomRight
  77.  
  78.     In corners mode, one can only move one tile at a time. The only
  79.     tiles that can be moved are the tile(s) next to both spaces. In the
  80.     other mode, one can move more than one tile at a time and one is
  81.     not constrained by parity.
  82.  
  83.     The title is in the following format (non-motif version):
  84.     xhexagons: <size> @ (<Number of moves>/\
  85.         {<Record number of moves>|NEVER|PRACTICE}) - <Comment>
  86.     {<Record...}: puzzle is either in practice mode or record mode
  87.        In record mode, if there is no record of the current puzzle, it
  88.        displays "NEVER".
  89.  
  90.     If you were looking for a auto-solver, sorry.
  91.  
  92.     Keep in mind that Hexagons is a widget that can be simply stuck in
  93.     other X programs. (If you find a use for this, let me know).
  94.  
  95.     Refer to the man page for detailed command line options.
  96.  
  97.     If you want further information on puzzles, I'll be glad :-) to send
  98.     it to you.
  99.  
  100. SAVE FORMAT
  101.  
  102.     The format is not standard.  The reason is that this is simple to
  103.     produce and I do not know what the standard is.  The format will
  104.     probably change to become more readable.
  105.  
  106.     size: number of tiles in a row
  107.     corners: 0 false, 1 true  hexagon corners
  108.     moves: 0-MAXINT
  109.  
  110.     startingPosition: array where 0 is the empty space for the HIGH hexagon
  111.       and -1 is the empty space for the LOW hexagon.
  112.  
  113.     This is then followed by the moves
  114.     move #: direction
  115.     Direction is represented as 0 upper right, 1 right, 2 lower right,
  116.       3 lower left, 4 left, and 5 upper left.
  117.  
  118.     Caution: the program may crash on corrupted input.
  119.  
  120. MATHEMATICAL BASIS
  121.  
  122.     Lets start out with a triangle of hexagons for simplicity's sake
  123.     and then expand these ideas to a hexagon of hexagons
  124.  
  125.     Assuming it is a triangle of i hexagons in each row and the
  126.     numbering starts from 1.
  127.        Corner 1-> 1
  128.               2-> i(i+1)/2 - i + 1
  129.               3-> i(i+1)/2
  130.  
  131.        Center ->i%3 =>
  132.               1: (2i'-1)*(2i')/2-i'+1 where i'= (i+2)/3
  133.               default: None
  134.  
  135.        Max_Width -> i * 3^(1/2) units
  136.        Max_Height -> (3/2)i+(1/2) units
  137.  
  138.        Start -> x= i * 3^(1/2)/2 units
  139.                 y=0
  140.                 fin=i
  141.                 step=i
  142.        Next -> (n==fin) =>
  143.                true: x+= -3^(1/2) * (2 * step - 1)/2 units; y+=3/2 units;
  144.                      step++; fin+=step
  145.                default: x+= 3^(1/2) units
  146.  
  147.        Same row? -> (m'==n') where s'=(1+sqrt_trunc(1+8*(s - 1)))/2 {k}
  148.                                 i.e. s = s'(s'-1)/2
  149.        Same trbl? -> (m-1)-m'(m'-1)/2 == (n-1)-n'(n'-1)/2 {i}
  150.        Same tlbr? -> (m'+1)m'/2-m == (n'+1)n'/2-n {j}
  151.  
  152.     Now assuming it is a hexagon of i hexagons in each row and
  153.     the numbering starts from 1.
  154.        Corner 1-> 1
  155.               2-> i
  156.               3-> Center - i + 1
  157.               4-> Center + i - 1
  158.               5-> 3i(i-1) - i + 2
  159.               6-> 3i(i-1) + 1
  160.  
  161.        Center -> 3i(i-1)/2 + 1
  162.  
  163.        Max_Width -> (2i-1) * 3^(1/2) units
  164.        Max_Height -> 3i-1 units
  165.  
  166.        Start -> x= i * 3^(1/2)/2 units
  167.                 y=0
  168.                 fin=i
  169.                 step=i
  170.        Next -> (n<=center) =>
  171.             true: (n==fin)
  172.               true: x+= -3^(1/2) * (2 * step - 1)/2 units; y+=3/2 units;
  173.                     step++; fin+=step
  174.               default: x+= 3^(1/2) units
  175.             default: (n==fin)
  176.               true: step--; x+= -3^(1/2) * (2 * step - 1)/2 units;
  177.                     y+=3/2 units; fin+=step
  178.               default: x+= 3^(1/2) units
  179.  
  180.        Same row? -> (m'==n') {k} where (s<=center) =>
  181.             true: s' = (1+sqrt_trunc(1+8*(s+i*(i-1)/2)))/2-i
  182.                            i.e. s = s'*(2s'-1)-(i)(i-1)/2
  183.             default: s' = 3*i-2-(1+sqrt_trunc(1+8*(3i(i-1)+1+i*(i-1)/2-s)))/2)
  184.        Same trbl? -> (m''==n'') {i} where (s<=center) =>
  185.             true: s'' = (s+i*(i-1)/2)-(s'+i)*(s'+i-1)/2
  186.             default: s'' = 2*i-2-(3i(i-1)+i*(i-1)/2-s-(3*i-s'-2)*(3*i-s'-3)/2)
  187.        Same tlbr? -> (m''==n'') {j} where (s<=center) =>
  188.             true: s'' = -1-((s+i*(i-1)/2)-(s'+i+1)*(s'+i)/2)
  189.             default: s'' = 2*i-1+(3i(i-1)+i*(i-1)/2-s-(3*i-s'-1)*(3*i-s'-2)/2)
  190.  
  191. FOUND A BUG?
  192.  
  193.     Send bugs reports and fixes to the author. For bugs, please include
  194.     as much information as to their location as possible, since I may not
  195.     have the resources to duplicate the them.
  196.  
  197.     David Albert Bagley,    bagleyd@hertz.njit.edu
  198.  
  199. HISTORY
  200.  
  201.   [Apr 08, 96]    V5.3: Minor changes.
  202.   [Jan 31, 96]    V5.2: If corners mode, a tile is now moved by a more
  203.         intuitive drag and drop approach.  Tiles will invert,
  204.         when selected.  Now using dynamic allocation, so there
  205.         is no maximum size.
  206.   [Dec 15, 95]    V5.1: Minor updates, RNG for 32/64 bit, border color
  207.         to make faces look more realistic.
  208.   [Oct 01, 95]    V5.0: Xt/Motif, your choice.
  209.   [May 16, 95]    V4.10: Warnings removed from Sun's cc and lint and now
  210.         include a random number generator.
  211.   [Mar 13, 95]    V4.5: Removed lint warnings and added a VMS make.com .
  212.   [Nov 11, 94]    V4.4: Conservative guess for random number generator.
  213.   [Nov 02, 94]    V4.3: Now allows undos, saves, and recalls.
  214.   [Aug 23, 94]    V4.2: Switched left and middle buttons on the mouse to
  215.         have up and down consistent with vi's "j", "k" keys.
  216.   [Jun 28, 94]    V4.1: Can accommodate a auto-solver.
  217.   [Jun 07, 94]    V4.0: Xt version.
  218.         I got some good ideas from oclock.
  219.   [Apr 01, 93]    V3.0: Motif version.
  220.         I got some good ideas from Douglas A. Young's
  221.         book: "The X Window System Programming and Applications
  222.         with Xt OSF/Motif Edition", particularly his dial widget.
  223.         I got some good ideas on presentation from Q. Zhao's
  224.         tetris.
  225.   [Jan 07, 92]    V2.0: XView version.
  226.   [Sep 06, 91]    V1.0: SunView version.
  227.